#ifndef INSTALL_WINDOW_H
#define INSTALL_WINDOW_H



#ifdef _DEBUG
   #define TRACE __Trace
#else
   #define TRACE
#endif

class CWindow
{
public:
   CWindow();
   virtual ~CWindow();

public:
   HWND GetHWND() const;
   operator HWND() const;

   bool RegisterWindowClass();

   HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, const RECT rc, HMENU hMenu = NULL);
   HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT, HMENU hMenu = NULL);

   HWND Subclass(HWND hWnd);
   void Unsubclass();
   void ShowWindow(bool bShow = true);
   void Close();
   void CenterWindow();
   void SetIcon(UINT nRes);

protected:
   virtual LPCTSTR GetWindowClassName() const = 0;
   virtual UINT GetClassStyle() const;

   LRESULT SendMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
   LRESULT PostMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);

   virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
   virtual void OnFinalMessage(HWND hWnd);

   static LRESULT CALLBACK __WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

protected:
   HWND m_hWnd;
   WNDPROC m_OldWndProc;
   bool m_bSubclassed;
};

#endif
